package com.sky.mapper.common;

import com.github.pagehelper.Page;
import com.sky.aop.AutoFill;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.enumeration.OperationType;
import com.sky.pojo.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {

    @Insert("insert into category  values (null,#{type}, #{name}, #{sort}, #{status}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
    @AutoFill(OperationType.INSERT)
    int save(Category category);

    @AutoFill(OperationType.UPDATE)
    int update(Category category);


    //@Select("select * from category where type = #{type} order by sort")
    Page<Category> pageQuery(CategoryPageQueryDTO pagedto);

    @Delete("delete from category where id = #{id}")
    int delete(Long id);

    @Select("select * from category where type = #{type}")
    List<Category> findByType(Integer type);

    @Select("select * from category where id = #{id}")
    Category findById(Long id);

    @Select("select * from category where status=1")
    List<Category> list();
}
